import type { CodeType } from '@/types/service'
import type { User } from '@/types/user'
import { request } from '@/utils/request'

// 发送短信验证码
const sendCodeAPI = (mobile: string, type: CodeType) => {
  return request('/code', 'GET', { mobile, type })
}
// 登录 ---- 密码登录
const loginByPswAPI = (mobile: string, password: string) => {
  return request<User>('/login/password', 'POST', { password, mobile })
}
// 登录 ---- 验证码登录
const loginByCodeAPI = (mobile: string, code: string) => {
  return request<User>('/login', 'POST', { mobile, code })
}
// 第三方登录
const loginByThird = (openId: string) => {
  return request<User>('login/thirdparty', 'POST', { openId, source: 'qq' })
}
// 第三方绑定手机号
const bindMobile = (u: { mobile: string; code: string; openId: string }) => {
  return request<User>('login/binding', 'POST', u)
}
export { sendCodeAPI, loginByPswAPI, loginByCodeAPI, loginByThird, bindMobile }
